package com.travelsmart.client.apresentacao.widget;

import java.util.Date;

import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.datepicker.client.DateBox;


public class FormDate extends FormWidget<Date>{
	private final DateBox dateBox = new DateBox();
	public final static String timeFormat = "dd/MM/yyyy";
    public final static DateTimeFormat dateFormat = DateTimeFormat.getFormat(timeFormat);


	public FormDate(final String infoHelp, final HandlerValidation<Date> handler){
		super(handler);
		dateBox.setFormat(new DateBox.DefaultFormat(dateFormat));
		super.panel.add(dateBox);
		super.initHelp(infoHelp);
		initWidget(panel);
	}
	
	public FormDate(final Date date, final String infoHelp, final HandlerValidation<Date> handler){
		super(handler);
		dateBox.setFormat(new DateBox.DefaultFormat(dateFormat));
		dateBox.setValue(date);
		super.panel.add(dateBox);
		super.initHelp(infoHelp);
		initWidget(panel);
	}
	
	public void setValue(Date date){
		dateBox.setValue(date);
	}

	
	public Date getValue(){
		return dateBox.getValue();
	}
	
	public String getValueString(){
		return dateBox.getTextBox().getValue();
	}
	@Override
	public void setFocus(boolean focused) {
		dateBox.setFocus(focused);
		
	}
}
